package edu.tyut.game.utils

object RegexUtils {
    fun userNameMatches(username: String): Boolean{
        // 中文, 英文, 数字, 下划线, 长度1-25
        val usernameRegex = Regex("^[\u4E00-\u9FA5A-Za-z\\d_]{1,25}$")
        return usernameRegex.matches(username)
    }
    fun passwordMatches(password: String): Boolean{
        // 必须字母开头, 可以包含 .~!@#$%^& +-*/= 特殊字符, 数字,字母,下划线,长度5-17
        val passwordRegex = Regex("^[a-zA-Z][.~!@#$%^&+\\-*/=\\w]{5,17}$")
        return passwordRegex.matches(password)
    }
    fun emailMatches(email: String): Boolean {
        val emailRegex = Regex("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$")
        return emailRegex.matches(email)
    }
    fun phoneMatches(phone: String): Boolean {
        val phoneRegex = Regex("^(13\\d|14[57]|15[^4]|16\\d|17\\d|18\\d|19\\d)\\d{8}$")
        return phoneRegex.matches(phone)
    }
}